package com.kevis.common.utils.expand;


import cn.hutool.core.convert.Convert;
import cn.hutool.http.HtmlUtil;
import org.springframework.util.StringUtils;

import java.time.LocalDateTime;

public class StringKevis {

    private String str;

    public StringKevis(String str) {
        this.str = str;
    }

    public StringKevis gg() {
        return null;
    }

    public String defaultIsNullOrEmpty(String defaultStr) {
        if (!StringUtils.hasLength(this.str))
            return defaultStr;
        return this.str.trim();
    }

    public int defaultIsNullOrEmpty(int defaultStr) {
        int result = defaultStr;
        if (StringUtils.hasLength(this.str)) {
            try {
                result = Integer.parseInt(this.str);
            } catch (NumberFormatException ex) {

            }
        }
        return result;
    }

    //region DefaultIsNullOrEmpty String型为空默认值 bool

    /**
     * 判断字符为空(默认值)
     *
     * @name 默认值
     * @name 默认值
     */
    public boolean defaultIsNullOrEmpty(boolean defaultBool) {
        boolean result = defaultBool;
        try {
            if (StringUtils.hasLength(this.str)) {

                result = Boolean.parseBoolean(this.str.toString().trim());
            }
        } catch (NumberFormatException ex) {
        }
        return result;
    }
    //endregion

    public LocalDateTime defaultIsNullOrEmpty(LocalDateTime defaultDateTime) {
        return Convert.toLocalDateTime(this.str, defaultDateTime);
    }

    //region RemoveHTML 移除HTML代码

    /**
     * 移除HTML代码
     */
    public String RemoveHTML() {
        if (StringUtils.hasLength(this.str)) {
            String a = HtmlUtil.cleanHtmlTag(this.str);
            String b = HtmlUtil.filter(this.str);
            String c = HtmlUtil.removeHtmlTag(this.str);
            String d = "";
        }
        return "";
    }
    //endregion
}
